﻿using Microsoft.SemanticKernel.Connectors.AI.OpenAI;
using Microsoft.SemanticKernel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SemanticKernelDemo
{
    internal class InLinePrompt
    {
        public static async Task<string> Run()
        {
            var builder = new KernelBuilder();

            var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();

            builder.WithOpenAIChatCompletionService(model, apiKey, orgId);

            var kernel = builder.Build();

            string skPrompt = @"
               WRITE EXACTLY ONE JOKE or HUMOROUS STORY ABOUT THE TOPIC BELOW

                JOKE MUST BE:
                - G RATED
                - WORKPLACE/FAMILY SAFE
                NO SEXISM, RACISM OR OTHER BIAS/BIGOTRY

                BE CREATIVE AND FUNNY. I WANT TO LAUGH.
                Incorporate the style suggestion, if provided: {{$style}}
                Answer me with Chinese
                +++++

                {{$input}}
                +++++

                ";

            var input = @"time travel to dinosaur age";

            var tldrFunction = kernel.CreateSemanticFunction(skPrompt, requestSettings: new OpenAIRequestSettings { MaxTokens = 2000, Temperature = 0.9, TopP = 0 });

            var summaryResult = await kernel.RunAsync(input, tldrFunction);
            var summary = summaryResult.GetValue<string>();

            Console.WriteLine(summary);
            return "";
        }
    }
}
